from appium import webdriver
import json

with open('../docs/desired_caps.json','r') as json_file:
    file_str = json_file.read()  #读入文件内容为字符串
    data = json.loads(file_str)
def getDriver():
    desired_caps = {}
    desired_caps['platformName'] = data['platformName']
    desired_caps['platformVersion']=data['platformVersion']
    desired_caps['deviceName']=data['deviceName']
    desired_caps['udid']=data['udid']
    desired_caps['noReset']=data['noReset']
    desired_caps['appPackage']=data['appPackage']
    desired_caps['appActivity']=data['appActivity']

    driver = webdriver.Remote('http://'+str(data['ip'])+':'+str(data['port'])+'/wd/hub', desired_caps)
    return driver
